/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cayumapu;

/**
 *
 * @author Solo_Pescadores
 */
public class Ctrl_VerificarRut {
    
    public String Verificar(int rut){
        int aux = rut,i=0,j=2,k=0;
        int[] array = new int[10];
        while(aux != 0){
            array[i]=aux%10;
            aux = aux/10;
            i=i+1;
        }
        while(i>=k){
            array[k]=array[k]*j;
            k++;
            j++;
            if(j==8)
                j=2;
        }
        k=0;
        aux=0;
        while(i>=k){
            aux = aux + array[k];
            k++;
        }
        aux = 11-aux%11;
        if (aux == 10)
            return "k";
        if (aux == 11)
            return "0";
        return Integer.toString(aux);
    }
    
}
